using UnityEngine;

namespace Gj
{
    public enum SimpleUIAnimationType
    {
        None,
        Rect
    }

    public class SimpleUIAnimationHelper : AnimationHelper
    {
        public SimpleUIAnimationType type = SimpleUIAnimationType.None;
        public bool init;
        public bool autoStart;
        public bool autoEnd;
        public Vector2 start = Vector2.zero;
        public Vector2 end = Vector2.zero;

        protected override void Init()
        {
            if (autoStart || autoEnd) AutoInit();
            if (init) OnUpdate(valueFrom);
        }

        private void AutoInit()
        {
            switch (type)
            {
                case SimpleUIAnimationType.Rect:
                    break;
            }
        }

        protected override void OnUpdate(float value)
        {
            Vector2 v;
            switch (type)
            {
                case SimpleUIAnimationType.Rect:
                    v = Vector2.Lerp(start, end, value);
                    Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, v.x);
                    Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, v.y);
                    break;
            }
        }
    }
}